<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>管理员与id关联</title>
    <script type="text/javascript" src="../common/jquery-3.2.1.js"></script>
    <script type="text/javascript" src="../common/commonQuery.js"></script>
    <script type="text/javascript" src="../common/commonManager.js"></script>
    <link rel="stylesheet" href="../common/common.css" type="text/css">
    <script type="text/javascript">

        function createTableHead() {
            var tr = "<tr>";
            tr += "<th align='left'>管理员id</th>"
            tr += "<th align='left'>id编码</th>"
            tr += "<th align='left'>操作</th>"
            tr += "</tr>"

            return tr;
        }

        function creteTableRow(info) {
            var tr = "<tr>";
            tr += "<td>" + info.managerId + "</td>";
            tr += "<td>" + info.targetId + "</td>";
            tr += "<td><button onclick='deleteEntity(\"" + info.managerId + "\",\"" + info.targetId + "\")'>删除</button></td>"
            tr += "</tr>"

            return tr;
        }

        function deleteEntity(managerId, targetId) {
            $.ajax({
                url: "../manager/relation/delete",
                data: {
                    managerId: managerId,
                    targetId: targetId
                },
                success: function (ajaxResult) {
                    if (ajaxResult.success) {
                        query();
                    } else {
                        alert("删除失败，原因：" + ajaxResult.message);
                    }
                }
            });
        }

    </script>
</head>
<body>
<br>
<div>
    <form id="queryForm" action="../manager/relation/query">
        管理员Id：<input type="text" name="managerId">
        id编码：<input type="text" name="targetId">
        <input type="button" onclick="pageNo = 1;query();" value="查询">
    </form>
</div>
<div id="tableDiv" class="table-solid"></div>
<div id="pageFoot">
    <button onclick="previousPage()">上一页</button>
    <span id="currentPageNo">1</span>
    <button onclick="nextPage()">下一页</button>
    总页数：<span id="totalPage"></span>
</div>
<br><br>
<div>
    新增关联：
    <form id="addForm" action="../manager/relation/add">
        <table>
            <tr>
                <td align="right">管理员id：</td>
                <td><input type="text" name="managerId"></td>
            </tr>
            <tr>
                <td align="right">id编码：</td>
                <td><input type="text" name="targetId"></td>
            </tr>
            <tr>
                <td align="right"><input type="button" onclick="requestServer('addForm')" value="提交"></td>
                <td></td>
            </tr>
        </table>
    </form>
</div>
</body>
</html>